package com.lixl.threadpool;

import java.util.Random;

public class AtomicIntDemo {

	public static void main(String[] args) {
		
		for (int i = 0; i < 100; i++) {
			int[] datas = getDatas();
			MulitTotalService service = new MulitTotalService();
			System.out.println(service.getTotal(datas)+"\t"+service.getTotalByAtomicInteger(datas)+"\t"+service.getTotalByLock(datas));
		}
		
	}
	
	private static int[] getDatas(){
		int[] datas = new int[100];
		
		for (int i = 0; i < datas.length; i++) {
			datas[i] = (int) (new Random().nextDouble()*20);
		}
		return datas;
	}
	

}
